#include <iostream>  
#include <vector>  
using namespace std;  
  
vector<int> mergeArrays(vector<int>& arr1, vector<int>& arr2) {  
    vector<int> mergedArr;  
    int i = 0, j = 0;  
      
    // 合并两个数组，按升序排序  
    while (i < arr1.size() && j < arr2.size()) {  
        if (arr1[i] < arr2[j]) {  
            mergedArr.push_back(arr1[i]);  
            i++;  
        } else {  
            mergedArr.push_back(arr2[j]);  
            j++;  
        }  
    }  
      
    // 将剩余的元素添加到合并后的数组中  
    while (i < arr1.size()) {  
        mergedArr.push_back(arr1[i]);  
        i++;  
    }  
    while (j < arr2.size()) {  
        mergedArr.push_back(arr2[j]);  
        j++;  
    }  
      
    return mergedArr;  
}  
  
int main() {  
    vector<int> arr1 = {1, 3, 5, 7};  
    vector<int> arr2 = {2, 4, 6, 8};  
    vector<int> mergedArr = mergeArrays(arr1, arr2);  
      
    cout << "Merged array: ";  
    for (int i = 0; i < mergedArr.size(); i++) {  
        cout << mergedArr[i] << " ";  
    }  
    cout << endl;  
      
    return 0;  
}